package com.aabte.design2.behavioral.visitor;

import com.google.common.collect.Lists;

import java.util.Collection;

/**
 * @author Daniel
 * @version 1.0
 * @date 2020/5/4
 */
public class Application {

    private Collection<Shape> shapes = Lists.newArrayList(
            new Dot(1, 2),
            new Circle(2, 3, 4),
            new Rectangle(5, 6, 7, 8)
    );

    public static void main(String[] args) {
        Application application = new Application();
        application.export();
    }

    public void export() {
        ExportVisitor exportVisitor = new ExportVisitor();
        for (Shape shape : shapes) {
            // 客户端代码可在不知晓具体类的情况下在一组元素上运行访问者操作。“接收”操
            // 作会将调用定位到访问者对象的相应操作上。
            shape.accept(exportVisitor);
        }
    }

}
